[#ftl]
[#include "commonDef.ftl" /]
[#assign toggleFlag=(data_main.fieldEx['toggleFlag']!'') oData = (other?? && toggleFlag?length>0)?then(other[toggleFlag],'') /]
[@ApiSqlHandler data_main=data_main data_method=data_method /][#--  主(左)--]

[#if toggleFlag?length>0]
[@ApiSqlHandler data_main=oData.data_main data_method=oData.data_method /][#--  子(右)--]
[/#if]

[#macro ApiSqlHandler data_main data_method]
[#assign uuidstr=uuidFunc()][#--  自增或序列自己修改--]
DO $$
DECLARE
  seqNo INTEGER;
BEGIN
  SELECT nextval('seq_sys_menu') INTO seqNo;
-- 菜单 SQL
insert into tbl_sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, remark)
values(seqNo,'${data_main.moduleKeyName}', '0', '1', '${data_main.moduleKey}', '${data_main.outputModulePath+'/'+data_main.moduleKey+'/'}index', '1', '0', 'C', '0', '0', '${PermissionFunc(data_main,"index")}', '', 'admin', now(), '');

-- 按钮 SQL
[#list data_method as mdx]
[#if mdx.needFlag == '1']
insert into tbl_sys_menu ( menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, remark)
    values('${ControllerMethodTitle(data_main,mdx)}', seqNo, '${mdx_index+1}',  '#', '', '1', '0', 'F', '0', '0', '${PermissionFunc(data_main,mdx.methodCode1)}', '', 'admin', now(), '');
[/#if]
[/#list]
END $$;
[/#macro]